﻿using System.Collections;
using System.Collections.Generic;
using tophd2.Classes.Helper;
using tophd2.Models.Entity;

namespace tophd2.Models.Service
{
    public class VideoService
    {
        public List<Video> GetVideo(long? cateId, long? oderby, int minrow, int maxrow)
        {
            JsonHelper<Video> jsonVideo = new JsonHelper<Video>();
            Hashtable hashtable = new Hashtable();
            hashtable.Add("categoryId", cateId);
            hashtable.Add("orderBy", oderby);
            hashtable.Add("minRow", minrow);
            hashtable.Add("maxRow", maxrow);
            string result = jsonVideo.GetJsonResponse("getVideo", hashtable);
            List<Video> listVideo = jsonVideo.ParseJsonResponse(result, "getVideoResponse");
            return listVideo;
        }

        public Video GetDetailVideo(long id)
        {
            List<Video> listVideo = GetVideo(0, 1, 0, 0);
            foreach (Video video in listVideo)
            {
                if (video.VideoId == id)
                {
                    return video;
                }
            }
            return null;
        }
    }
}